<template>
  <div class="_wz_cent_main _wz_TravelLogAdd">

    <Form ref="formAdd" :model="formData" label-position="right" :label-width="120" :rules="ruleValidate">
      <Card dis-hover :bordered="true" style="margin:0 0 10px;">
        <p slot="title">基本信息</p>
        <div>
          <Row>
            <Col span="8">
              <FormItem label="运输企业" prop="deptUuid">
                <i-select v-model="formData.deptUuid" filterable placeholder="请选择运输企业" clearable @on-clear="changeSelectedDept" :disabled="formData.id">
                  <Option v-for="item in subDeptList" :value="item.uuid" :key="item.uuid"  @click.native="changeSelectedDept(item)">{{ item.deptName }}</Option>
                </i-select>
              </FormItem>
            </Col>
            <Col span="16">
              <FormItem label="天气情况">
                <RadioGroup v-model="formData.weather">
                  <Radio label="晴"></Radio>
                  <Radio label="阴"></Radio>
                  <Radio label="雪"></Radio>
                  <Radio label="雨"></Radio>
                  <Radio label="雾"></Radio>
                  <Radio label="冰冻"></Radio>
                  <Radio label="大风"></Radio>
                  <Radio label="冰雹"></Radio>
                </RadioGroup>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="运输车辆" prop="vehicleUuid">
                <i-select v-model="formData.vehicleUuid" filterable placeholder="请选择运输车辆" :label-in-value="true" clearable>
                  <Option v-for="item in vehicleList" :value="item.uuid" :key="item.uuid">{{item.carPlateNo }}</Option>
                </i-select>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="从业人员" prop="driverUuid">
                <i-select v-model="formData.driverUuid" filterable placeholder="请选择从业人员" clearable @on-change="changeSelectedStaff">
                  <Option v-for="item in staffList" :value="item.uuid" :key="item.uuid" @click.native="changeSelectedDriver(item)">{{item.name }}</Option>
                </i-select>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="运输性质" prop="goods">
                <i-input v-model="formData.goods" placeholder="运输性质" clearable />
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="发车时间" prop="beginDate">
                <DatePicker v-model="formData.beginDate" type="datetime" placeholder="发车时间"></DatePicker>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="收车时间" prop="endDate">
                <DatePicker v-model="formData.endDate" type="datetime" placeholder="收车时间"></DatePicker>
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="额定荷载" prop="ratedLoad">
                <i-input v-model="formData.ratedLoad" placeholder="额定荷载" clearable />
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="发车地点" prop="beginLocation">
                <i-input v-model="formData.beginLocation" placeholder="发车地点" clearable />
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="收车地点" prop="endLocation">
                <i-input v-model="formData.endLocation" placeholder="收车地点" clearable />
              </FormItem>
            </Col>
            <Col span="8">
              <FormItem label="实际荷载" prop="actualLoad">
                <i-input v-model="formData.actualLoad" placeholder="实际荷载" clearable />
              </FormItem>
            </Col>

          </Row>
        </div>
      </Card>
      <Card dis-hover :bordered="true" style="margin:0 0 10px;">
        <p slot="title">行车安全问询</p>
        <FormItem label="行车问询">
          <div style="line-height: 32px;">
            <template v-if="beforeRemindContext.length > 0">
              <template v-for="item,index in beforeRemindContext">
                <div>
                  {{ index+1}}. {{item.remindName}}
                  <span style="margin: 0 0 0 30px;">
                    <RadioGroup v-model.number="item.remindResult">
                      <Radio :label="1">正确</Radio>
                      <Radio :label="0">错误</Radio>
                    </RadioGroup>
                  </span>
                </div>
              </template>
            </template>
            <span v-else style="color: #ed4014;">选择企业后才可以操作问询项</span>
            <!--          beforeRemindContext-->
          </div>
        </FormItem>

      </Card>
      <Card dis-hover :bordered="true" style="margin:0 0 10px;">
        <p slot="title">出车前检查</p>

        <FormItem label="检查项">
          <template v-if="beforeCheckContext.length > 0">
            <template v-for="item,index in beforeCheckContext">
              <Checkbox :label="item.checkResult" :false-value="0" :true-value="1" v-model.number="item.checkResult">
                {{item.checkName+'：'+item.checkValue}}
              </Checkbox>
              <br />
            </template>
          </template>
          <span v-else style="color: #ed4014;">选择企业后才可以操作检查项</span>
        </FormItem>
        <FormItem label="出车结论" prop="beforeConclusion">
          <RadioGroup v-model="formData.beforeConclusion">
            <Radio :label="0">不符合出车要求</Radio>
            <Radio :label="1">良好可以行驶</Radio>
          </RadioGroup>
        </FormItem>
        <Row>
          <Col span="8">
            <FormItem label="检查人" prop="beforeCheckUser">
              <i-input v-model="formData.beforeCheckUser" placeholder="检查人" clearable />
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="检查时间" prop="beforeCheckTime">
              <DatePicker type="datetime" v-model="formData.beforeCheckTime" placeholder="请选择检查时间" split-panels clearable></DatePicker>
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span="8">
            <FormItem label="检查记录">
              <Upload :before-upload="beforeCheckImgFileFun" action="" style="color: #2d8cf0;cursor: pointer;">上传检查记录照片
              </Upload>
              <div class="demo-upload-list">
                <viewer style="width: 100%;height: 100%;">
                  <img :src="!!beforeCheckImgFile.url?beforeCheckImgFile.url:'../../static/img/zwtpxd.png'" @error="public.imgDispose">
                </viewer>
              </div>
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="签字照片">
              <Upload :before-upload="beforeSignImgFileFun" action="" style="color: #2d8cf0;cursor: pointer;">上传签字照片
              </Upload>
              <div class="demo-upload-list">
                <viewer style="width: 100%;height: 100%;">
                  <img :src="!!beforeSignImgFile.url?beforeSignImgFile.url:'../../static/img/zwtpxd.png'" @error="public.imgDispose">
                </viewer>
              </div>
            </FormItem>
          </Col>
        </Row>
        <FormItem label="故障处理" prop="beforeTroubleshooting">
          <i-input v-model="formData.beforeTroubleshooting" placeholder="故障处理" type="textarea" :rows="4" />
        </FormItem>
      </Card>
      <Card dis-hover :bordered="true" style="margin:0 0 10px;">
        <p slot="title">行车中检查</p>
        <FormItem label="检查项">
          <template v-if="midwayCheckContext.length > 0">
            <template v-for="item,index in midwayCheckContext">
              <Checkbox :label="item.checkResult" :false-value="0" :true-value="1" v-model.number="item.checkResult">
                {{item.checkName+'：'+item.checkValue}}
              </Checkbox>
              <br />
            </template>
          </template>
          <span v-else style="color: #ed4014;">选择企业后才可以操作检查项</span>
        </FormItem>
        <Row>
          <Col span="8">
            <FormItem label="检查人" prop="midwayCheckUser">
              <i-input v-model="formData.midwayCheckUser" placeholder="检查人" clearable />
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="检查时间" prop="midwayCheckTime">
              <DatePicker type="datetime" v-model="formData.midwayCheckTime" placeholder="请选择检查时间" split-panels clearable></DatePicker>
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span="8">
            <FormItem label="检查记录">
              <Upload :before-upload="midwayCheckImgFileFun" action="" style="color: #2d8cf0;cursor: pointer;">上传检查记录照片
              </Upload>
              <div class="demo-upload-list">
                <viewer style="width: 100%;height: 100%;">
                  <img :src="!!midwayCheckImgFile.url?midwayCheckImgFile.url:'../../static/img/zwtpxd.png'" @error="public.imgDispose">
                </viewer>
              </div>
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="签字照片">
              <Upload :before-upload="midwaySignImgFileFun" action="" style="color: #2d8cf0;cursor: pointer;">上传签字照片
              </Upload>
              <div class="demo-upload-list">
                <viewer style="width: 100%;height: 100%;">
                  <img :src="!!midwaySignImgFile.url?midwaySignImgFile.url:'../../static/img/zwtpxd.png'" @error="public.imgDispose">
                </viewer>
              </div>
            </FormItem>
          </Col>
        </Row>
        <FormItem label="故障处理" prop="midwayTroubleshooting">
          <i-input v-model="formData.midwayTroubleshooting" placeholder="故障处理" type="textarea" :rows="4" />
        </FormItem>
      </Card>
      <Card dis-hover :bordered="true" style="margin:0 0 10px;">
        <p slot="title">收车后检查</p>

        <FormItem label="检查项">
          <template v-if="afterCheckContext.length > 0">
            <template v-for="item,index in afterCheckContext">
              <Checkbox :label="item.checkResult" :false-value="0" :true-value="1" v-model.number="item.checkResult">
                {{item.checkName+'：'+item.checkValue}}
              </Checkbox>
              <br />
            </template>
          </template>
          <span v-else style="color: #ed4014;">选择企业后才可以操作检查项</span>
        </FormItem>
        <Row>
          <Col span="8">
            <FormItem label="检查人" prop="afterCheckUser">
              <i-input v-model="formData.afterCheckUser" placeholder="检查人" clearable />
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="检查时间" prop="afterCheckTime">
              <DatePicker type="datetime" v-model="formData.afterCheckTime" placeholder="请选择检查时间" split-panels clearable></DatePicker>
            </FormItem>
          </Col>
        </Row>
        <Row>
          <Col span="8">
            <FormItem label="检查记录">
              <Upload :before-upload="afterCheckImgFileFun" action="" style="color: #2d8cf0;cursor: pointer;">上传检查记录照片
              </Upload>
              <div class="demo-upload-list">
                <viewer style="width: 100%;height: 100%;">
                  <img :src="!!afterCheckImgFile.url?afterCheckImgFile.url:'../../static/img/zwtpxd.png'" @error="public.imgDispose">
                </viewer>
              </div>
            </FormItem>
          </Col>
          <Col span="8">
            <FormItem label="签字照片">
              <Upload :before-upload="afterSignImgFileFun" action="" style="color: #2d8cf0;cursor: pointer;">上传签字照片
              </Upload>
              <div class="demo-upload-list">
                <viewer style="width: 100%;height: 100%;">
                  <img :src="!!afterSignImgFile.url?afterSignImgFile.url:'../../static/img/zwtpxd.png'" @error="public.imgDispose">
                </viewer>
              </div>
            </FormItem>
          </Col>
        </Row>
        <FormItem label="故障处理" prop="afterTroubleshooting">
          <i-input v-model="formData.afterTroubleshooting" placeholder="故障处理" type="textarea" :rows="4" />
        </FormItem>
      </Card>
    </Form>
    <div class="demo-drawer-footer">
      <Button style="margin-right: 8px" @click="$emit('closeFun', false)">取消</Button>
      <Button type="primary" @click="addSubmit('formAdd')">提交</Button>
    </div>
  </div>
</template>
<script>
export default {
  props: ['selectData'],//接收来自父组件的数据
  data() {
    return {
      uploadProgress: 0,//文件上传进度
      beforeRemindContext:[],//询问项
      ruleValidate: {
        deptUuid: [
          {required: true, message: '请选择运输企业', trigger: 'blur'},
        ],
        vehicleUuid: [
          {required: true, message: '请选择运输车辆', trigger: 'blur'},
        ],
        driverUuid: [
          {required: true, message: '请选择从业人员', trigger: 'blur'},
        ],
        goods: [
          {required: true, message: '请填写运输性质', trigger: 'blur'},
        ],
        beginDate: [
          {type: "date",required: true, message: '请选择发车时间', trigger: 'blur'},
        ],
        endDate: [
          {type: "date",required: true, message: '请选择收车时间', trigger: 'blur'},
        ],
        ratedLoad: [
          {required: true, message: '请填写额定荷载', trigger: 'blur'},
        ],
        beginLocation: [
          {required: true, message: '请填写发车地点', trigger: 'blur'},
        ],
        endLocation: [
          {required: true, message: '请填写收车地点', trigger: 'blur'},
        ],
        actualLoad: [
          {required: true, message: '请填写实际荷载', trigger: 'blur'},
        ],
        beforeCheckUser: [
          {required: true, message: '请填写检查人', trigger: 'blur'},
        ],
        beforeCheckTime: [
          {type: "date",required: true, message: '请选择检查时间', trigger: 'blur'},
        ],
        beforeTroubleshooting: [
          {required: true, message: '请填写故障处理', trigger: 'blur'},
        ],
        midwayCheckUser: [
          {required: true, message: '请填写检查人', trigger: 'blur'},
        ],
        midwayCheckTime: [
          {type: "date",required: true, message: '请选择检查时间', trigger: 'blur'},
        ],
        midwayTroubleshooting: [
          {required: true, message: '请填写故障处理', trigger: 'blur'},
        ],
        afterCheckUser: [
          {required: true, message: '请填写检查人', trigger: 'blur'},
        ],
        afterCheckTime: [
          {type: "date",required: true, message: '请选择检查时间', trigger: 'blur'},
        ],
        afterTroubleshooting: [
          {required: true, message: '请填写故障处理', trigger: 'blur'},
        ],
      },
      formData: {
        deptUuid: '',
        beforeTroubleshooting: '无',
        midwayTroubleshooting: '无',
        afterTroubleshooting: '无',
        beforeConclusion: 1,
        weather: "晴"
      },//出车日志基本信息
      beforeCheckContext:[],//行车前检查项记录
      midwayCheckContext:[],//行车中检查项记录
      afterCheckContext:[],//收车后检查项记录


      subDeptList: [],//企业列表
      vehicleList: [],//车辆列表
      staffList: [],//从业人员

      beforeCheckImgFile:{//出车前检查记录照片
        data:null,
        url:'',
      },
      beforeSignImgFile:{//出车前签字记录照片
        data:null,
        url:'',
      },
      midwayCheckImgFile:{//行车中检查记录照片
        data:null,
        url:'',
      },
      midwaySignImgFile:{//行车中签字记录照片
        data:null,
        url:'',
      },
      afterCheckImgFile:{//收车后检查记录照片
        data:null,
        url:'',
      },
      afterSignImgFile:{//收车后签字记录照片
        data:null,
        url:'',
      },
    }
  },
  computed: {//计算属性

  },
  beforeCreate() {//beforeCreate创建前状态

  },
  created() {//created创建完毕状态

  },
  beforeMount() {//beforeMount挂载前状态   DOM 元素然后塞入页面的过程

  },
  mounted() {//mounted 挂载结束状态
    var that = this;

    if(!!that.selectData.id){
      that.axios.post(that.apiUrl.webApi + '/safety/drivingLog/drivingLogInfo', {uuid: that.selectData.uuid}).then(res => {
        if (!!res) {
          that.loadVehicleList(res.data.data.deptUuid)
          that.loadStaffList(res.data.data.deptUuid)
          that.formData = res.data.data;//出车信息


          that.beforeCheckContext = JSON.parse(res.data.data.beforeCheckContext);
          that.midwayCheckContext = JSON.parse(res.data.data.midwayCheckContext);
          that.afterCheckContext = JSON.parse(res.data.data.afterCheckContext);


          that.beforeRemindContext = JSON.parse(res.data.data.beforeRemindContext);


          that.beforeCheckImgFile.url = !!res.data.data.beforeCheckImg?that.apiUrl.imgUrl + res.data.data.beforeCheckImg:'';//出车前检查记录照片
          that.beforeSignImgFile.url = !!res.data.data.beforeSignImg?that.apiUrl.imgUrl + res.data.data.beforeSignImg:'';//出车前签字记录照片
          that.midwayCheckImgFile.url = !!res.data.data.midwayCheckImg?that.apiUrl.imgUrl + res.data.data.midwayCheckImg:'';//行车中检查记录照片
          that.midwaySignImgFile.url = !!res.data.data.midwaySignImg?that.apiUrl.imgUrl + res.data.data.midwaySignImg:'';//行车中签字记录照片
          that.afterCheckImgFile.url = !!res.data.data.afterCheckImg?that.apiUrl.imgUrl + res.data.data.afterCheckImg:'';//收车后检查记录照片
          that.afterSignImgFile.url = !!res.data.data.afterSignImg?that.apiUrl.imgUrl + res.data.data.afterSignImg:'';//收车后签字记录照片
        }
      }).catch(err => {
        console.log("失败", err)
      })
    }

    /*加载子企业列表*/
    that.axios.post(that.apiUrl.coreDeptCoreDeptList, {}).then(res => {
      if (!!res) {
        that.formData.deptUuid = res.data.data[0].uuid;
        that.subDeptList = res.data.data;
        if(!that.selectData.id) {
          that.checkEntry(that.subDeptList[0])
          that.loadVehicleList(that.subDeptList[0].uuid)
          that.loadStaffList(that.subDeptList[0].uuid)
          that.inquiries(that.subDeptList[0].uuid)
        }
      }
    }).catch(err => {
      console.log("失败", err)
    })
  },
  methods: {//执行的方法
    //企业类型  检查项
    checkEntry(data){
      var that = this;
      that.axios.post(that.apiUrl.webApi + '/safety/drivingLog/drivingLogCheckList', {deptUuid:data.uuid}).then(res => {
        if (!!res) {

          var beforeCheckContext = [],//行车前检查项记录
          midwayCheckContext = [],//行车中检查项记录
          afterCheckContext = [];//收车后检查项记录
          for (let i = 0; i < res.data.data.length; i++) {
            if(res.data.data[i].checkType == 1){
              beforeCheckContext.push({
                checkType: res.data.data[i].checkType,
                checkName: res.data.data[i].checkName,
                checkValue: res.data.data[i].checkValue,
                checkResult: 1//'1'
              })
            }
            if(res.data.data[i].checkType == 2){
              midwayCheckContext.push({
                checkType: res.data.data[i].checkType,
                checkName: res.data.data[i].checkName,
                checkValue: res.data.data[i].checkValue,
                checkResult: 1//'1'
              })
            }
            if(res.data.data[i].checkType == 3){
              afterCheckContext.push({
                checkType: res.data.data[i].checkType,
                checkName: res.data.data[i].checkName,
                checkValue: res.data.data[i].checkValue,
                checkResult: 1//'1'
              })
            }
          }
          that.beforeCheckContext = beforeCheckContext;
          that.midwayCheckContext = midwayCheckContext;
          that.afterCheckContext = afterCheckContext;
        }
      }).catch(err => {
        console.log("失败", err)
      })
    },
    //运输企业
    changeSelectedDept(e) {
      if (!!e) {
        this.loadVehicleList(e.uuid)
        this.loadStaffList(e.uuid)
        this.checkEntry(e)
        this.inquiries(e.uuid)
      } else {
        this.vehicleList = [];
        this.staffList = [];

        this.beforeCheckContext = [];
        this.midwayCheckContext = [];
        this.afterCheckContext = [];
        this.beforeRemindContext = [];
      }
    },
    //问询项
    inquiries(data){
      var that = this;
      that.axios.post(that.apiUrl.webApi + "/safety/drivingLog/drivingLogRemindList", {deptUuid: data}).then(res => {
        if (!!res) {
          res.data.data.forEach(function (k, i) {
            k.remindResult = k.remindAnswer;
          })

          that.beforeRemindContext = res.data.data;
        }
      }).catch(err => {
        console.log('失败', err);
      })
    },
    // 选择人员 清楚
    changeSelectedStaff(e) {
      if (!e) {
        this.formData.beforeCheckUser = '';//出车<br/>前检<br/>查
        this.formData.midwayCheckUser = '';//行车<br/>中检<br/>查
        this.formData.afterCheckUser = '';//收车<br/>后检<br/>查
      }
    },
    //人员赋值
    changeSelectedDriver(item) {
      this.$set(this.formData, 'beforeCheckUser', item.name);//出车<br/>前检<br/>查
      this.$set(this.formData, 'midwayCheckUser', item.name);//行车<br/>中检<br/>查
      this.$set(this.formData, 'afterCheckUser', item.name);//收车<br/>后检<br/>查
    },
    /*车牌号列表数据加载*/
    loadVehicleList(deptUuid) {
      var that = this;
      that.axios.post(that.apiUrl.webApi + "/core/vehicle/coreVehicleList", {deptUuid: deptUuid}).then(res => {
        if (res) {
          that.vehicleList = res.data.data
        }
      }).catch(err => {
        console.log("失败", err)
      })
    },
    /*从业人员数据加载*/
    loadStaffList(deptUuid) {
      var that = this;
      that.axios.post(that.apiUrl.coreDriverCoreDriverList, {deptUuid: deptUuid, binding: 1}).then(res => {
        if (res) {
          that.staffList = res.data.data
        }
      }).catch(err => {
        console.log("失败", err)
      })
    },
    beforeCheckImgFileFun(file) {//出车前检查记录照片
      let that = this;
      let type = file.type.split("/")[0];
      if (type == "image") {//图片
        that.beforeCheckImgFile.url = window.URL.createObjectURL(file);
        that.beforeCheckImgFile.data = file;
      } else {
        that.$Message.warning('请选择jpg、png、jpeg的图片进行上传');
      }
      return false;
    },
    beforeSignImgFileFun(file) {//出车前签字记录照片
      let that = this;
      let type = file.type.split("/")[0];
      if (type == "image") {//图片
        that.beforeSignImgFile.url = window.URL.createObjectURL(file);
        that.beforeSignImgFile.data = file;
      } else {
        that.$Message.warning('请选择jpg、png、jpeg的图片进行上传');
      }
      return false;
    },
    midwayCheckImgFileFun(file) {//行车中检查记录照片
      let that = this;
      let type = file.type.split("/")[0];
      if (type == "image") {//图片
        that.midwayCheckImgFile.url = window.URL.createObjectURL(file);
        that.midwayCheckImgFile.data = file;
      } else {
        that.$Message.warning('请选择jpg、png、jpeg的图片进行上传');
      }
      return false;
    },
    midwaySignImgFileFun(file) {//行车中签字记录照片
      let that = this;
      let type = file.type.split("/")[0];
      if (type == "image") {//图片
        that.midwaySignImgFile.url = window.URL.createObjectURL(file);
        that.midwaySignImgFile.data = file;
      } else {
        that.$Message.warning('请选择jpg、png、jpeg的图片进行上传');
      }
      return false;
    },
    afterCheckImgFileFun(file) {//收车后检查记录照片
      let that = this;
      let type = file.type.split("/")[0];
      if (type == "image") {//图片
        that.afterCheckImgFile.url = window.URL.createObjectURL(file);
        that.afterCheckImgFile.data = file;
      } else {
        that.$Message.warning('请选择jpg、png、jpeg的图片进行上传');
      }
      return false;
    },
    afterSignImgFileFun(file) {//收车后签字记录照片
      let that = this;
      let type = file.type.split("/")[0];
      if (type == "image") {//图片
        that.afterSignImgFile.url = window.URL.createObjectURL(file);
        that.afterSignImgFile.data = file;
      } else {
        that.$Message.warning('请选择jpg、png、jpeg的图片进行上传');
      }
      return false;
    },
    //
    addSubmit (name) {//新增修改提交
      var that = this
      that.$refs[name].validate((valid) => {
        if (valid) {//正则判断使用
          var data = JSON.parse(JSON.stringify(that.formData));
          delete data.shiftList;
          //data.shiftList = JSON.parse(JSON.stringify(that.shiftRecord));//在途交班记录
          data.beforeCheckContext = JSON.stringify(that.beforeCheckContext);//检查项
          data.midwayCheckContext = JSON.stringify(that.midwayCheckContext);//检查项
          data.afterCheckContext = JSON.stringify(that.afterCheckContext);//检查项


          data.beforeRemindContext = JSON.stringify(that.beforeRemindContext);//检查项


          !!data.afterCheckTime ? data.afterCheckTime = that.public.timeFormatting(data.afterCheckTime, "yyyy-MM-dd hh:mm:ss") : '';
          !!data.beginDate ? data.beginDate = that.public.timeFormatting(data.beginDate, "yyyy-MM-dd hh:mm:ss") : '';
          !!data.endDate ? data.endDate = that.public.timeFormatting(data.endDate, "yyyy-MM-dd hh:mm:ss") : '';
          !!data.beforeCheckTime ? data.beforeCheckTime = that.public.timeFormatting(data.beforeCheckTime, "yyyy-MM-dd hh:mm:ss") : '';
          !!data.midwayCheckTime ? data.midwayCheckTime = that.public.timeFormatting(data.midwayCheckTime, "yyyy-MM-dd hh:mm:ss") : '';

          data.checkContext = JSON.stringify(data.detailList);//行车前检查项

          let formData = new FormData();
          for (let key in data) {
            if (!!data[key]) {
              formData.append(key, data[key]);
            }
          }
          if(!!that.beforeCheckImgFile.data){//出车前检查记录照片
            formData.append('beforeCheckImgFile', that.beforeCheckImgFile.data);
          }
          if(!!that.beforeSignImgFile.data){//出车前签字记录照片
            formData.append('beforeSignImgFile', that.beforeSignImgFile.data);
          }
          if(!!that.midwayCheckImgFile.data){//行车中检查记录照片
            formData.append('midwayCheckImgFile', that.midwayCheckImgFile.data);
          }
          if(!!that.midwaySignImgFile.data){//行车中签字记录照片
            formData.append('midwaySignImgFile', that.midwaySignImgFile.data);
          }
          if(!!that.afterCheckImgFile.data){//收车后检查记录照片
            formData.append('afterCheckImgFile', that.afterCheckImgFile.data);
          }
          if(!!that.afterSignImgFile.data){//收车后签字记录照片
            formData.append('afterSignImgFile', that.afterSignImgFile.data);
          }


          that.axios.post(that.apiUrl.webApi + '/safety/drivingLog/drivingLogSaveOrUpdate', formData, that.public.parameterUploadProgress(that)).then(res => {
            that.$Spin.hide();
            if (res) {
              that.$Message.success('操作成功');
              that.$emit('closeFun', true)
            }
          }).catch(err => {
            console.log("失败", err)
          })

        } else {
          this.$Message.error('请正确填写表单')
        }
      })
    },
  },
  watch: {//监听

  },
  beforeUpdate() {//beforeUpdate 更新前状态

  },
  updated() {//updated 更新完成状态

  },
  beforeDestroy() {//beforeDestroy 销毁前状态

  },
  destroyed() {//destroyed 销毁完成状态

  }
}
</script>
<style lang="less">
._wz_TravelLogAdd{

  .demo-upload-list {
    display: inline-block;
    width: 200px;
    height: 140px;
    text-align: center;
    line-height: 140px;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    position: relative;
    border: 1px solid rgba(0, 0, 0, .2);
    margin-right: 4px;

    img {
      width: 100%;
      height: 100%;
    }
  }
}


</style>
